package day13;

import org.junit.Test;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;

public class User {
    int id;
    String name;
    int age;
    public User(int id, String name, int age) {
        this.id = id;
        this.name = name;
        this.age = age;
    }

    public String toString() {
        return "User{" + "id=" + id + ", name='" + name + '\'' + ", age=" + age + '}';
    }
    public static void main(String[] args) {
        Test1 test1=new Test1();
        test1.List();
    }

}
class Test1{
    @Test
    public void List(){
        List<User> list=new ArrayList<>();
        list.add(new User(1,"万鑫",18));
        list.add(new User(3,"张三",18));
        list.add(new User(6,"李四",18));
        list.add(new User(7,"志广",18));
        list.add(new User(9,"王五",18));
        list.add(new User(18,"茜茜",18));
        list.add(new User(11,"金科",18));
        list.add(new User(19,"秦王",18));
        list.add(new User(20,"乾隆",18));
        list.add(new User(5,"松哥",18));
        Iterator it=list.iterator();
        while(it.hasNext()){
            User user = (User) it.next();
            System.out.println(user);
        }

    }
}